package StudyCode.summary.Basic.mystring;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class StringConnect {
	public static void main(String[] args){
		concatExample();
		concatOperatorExample();
		stringBuilderExample();
		stringBufferExample();
	}
	public static void concatExample(){
		String one = "Hello";
		String two = "World";
		String result = one.concat(" ".concat(two));

		System.out.println(result);
	}

	public static void concatOperatorExample(){
		String one = "Hello";
		String two = "World";
		String result = one + " " + two;

		System.out.println(result);
	}

	public static void stringBuilderExample(){
		String one = "Hello";
		String two = "World";
		StringBuilder builder = new StringBuilder();
		builder.append(one).append(" ").append(two);
		System.out.println(builder.toString());
	}

	public static void stringBufferExample(){
		String one = "Hello";
		String two = "World";
		StringBuffer buffer = new StringBuffer();
		buffer.append(one).append(" ").append(two);

		String result = buffer.toString();

		System.out.println(result);
	}
}
